;10-5.asm 显示字符移动动画效果
include 9004.mac		  ;宏库	    
displd macro   opr   	 ;字母显示消隐宏。在当前光标位置写字符或空格
     mov ah,0ah              
     mov al,opr
     mov bh,00h
     mov cx,01h
     int 10h
endm
displs macro   opr 		;显示字符串宏
     mov ah,09h              
     mov dx,opr			  ;opr应为字串偏移地址
     int 21h
endm
delay macro 	   		;延时宏
local rept1,rept2
mov cx,15000
rept1:push cx
rept2:loop rept2
pop cx
loop rept1
endm
;-----------------------------------------------
data segment			 
w_s0 db 'Knowledge is power.','$' 
w_s1 db 'Practice makes perfect.','$'
w_s2 db 'I wish you success!','$'
w_s3 db ?
table dw w_s0,w_s1,w_s2,w_s3	  ;存储单元地址表
w_row db 4	
w_col db 50
w_width db ?
x db 3							;3行字符串
data ends
;-----------------------------------------------
code segment
   assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
clearsc						  ;清屏
xor ax,ax
mov al,w_col					  ;列
mov si,0
rept1:
push ax			  			;保存列值
cursor w_row,w_col  			 ;置光标4行50列
mov bx,table[si+2]			   ;第2个字串地址w_s1→bx	  
sub bx,table[si]			 ;两个单元地址相减如 w_s1-w_s0
mov w_width,bl				   ;获得字串长度
call w_move					   ;调用字串移动子程序
pop ax
mov w_col,al					  ;恢复列值
inc w_row 					    ;下一行
add si,2
dec x
jnz rept1
mov ah,4ch
int 21h 
;子程序
w_move proc near
let0:
delay							;延时
dec w_col						;光标左移
cursor w_row,w_col
displs table[si]				 ;显示w_s0等单元中的字串
mov dl,w_col
dec dl
add dl,w_width				   ;光标置于串尾
cursor w_row,dl
displd 20h					   ;消隐尾部字符
dec bx
cmp bx,0
jnz let0						 ;串继续左移
ret
w_move endp              
code ends
end start     